package com.lh.java.junit;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class TestCalcu {
	private static Calculator calculator = new Calculator();

	@Before
	public void setUp() throws Exception {
		calculator.clear();
	}

	@SuppressWarnings("deprecation")
	@Test
	public void testAdd() {
		calculator.add(2);
		calculator.add(3);
		assertEquals(5, calculator.getResult());		
	}

	@SuppressWarnings("deprecation")
	@Test(expected=Exception.class)
	public void testSub() {
		calculator.sub(0);
		assertEquals(0,calculator.getResult());
	}

	@Test(timeout = 2000)
	public void testSquare() {
		calculator.square(0);
	}

	@Ignore
	public void testSquareRoot() {
		calculator.clear();
	}

}
